Class sjl.SingleList
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sjl.SingleList

java.lang.Object
   |
   +----sjl.SingleList

public class SingleList
extends Object
implements FrontInsertContainer
SingleList is a kind of sequence that supports forward iterators and allow constant time insert and erase operations anywhere within the sequense, with storage management handled automatically. Unlike vectors and deques, fast random access to list elements are not suported, but many algorithms only need sequential access anyway.

insert does not affect the validity of iterators. Insertion of a single element into a list takes constant time. Insertion of multiple elements into a list is linear in the number of elements inserted.

erase invalidates only the iterators to the erased elements. Erasing a single element is constant time. Erasing a range in a list is linear time in the size of the range.

Copyright © 1996 Finn Bock


Constructor Index

 o SingleList()
Constructs an empty list.
 o SingleList(InputIterator, InputIterator)
Constructs a list with elements found in the range [first,last).
 o SingleList(int, Object)
Constructs a list with n element each pointing to value.
 o SingleList(SingleList)
Constructs a list with all the elements from another list.

Method Index

 o back()
Returns the last element in the list.
 o begin()
Returns the iterator that represents the beginning of the list.
 o beginGeneric()
Returns the iterator that represents the beginning of the list as a untyped iterator.
 o beginRef()
Returns a reference to the iterator that represents the beginning of the list.
 o empty()
Returns true if the list does not contain any elements.
 o end()
Returns the iterator that represents the end of the list.
 o endGeneric()
Returns the iterator that represents the end of the list as a untyped iterator.
 o endRef()
Returns a reference to the iterator that represents the end of the list.
 o equals(Object)
Compare the elements in this container with the elements in another container.
 o erase(Iterator)
Remove the element to which the iterator points.
 o erase(Iterator, Iterator)
Remove the elements in the range [first,last) from the list.
 o flush()
Erase all the elements in the container.
 o front()
Returns the first element in the list.
 o insert(Iterator, InputIterator, InputIterator)
Insert the element in the range [first,last) into the list at the specified position.
 o insert(Iterator, int, Object)
Insert n copy of the element at the specified position.
 o insert(Iterator, Object)
Insert the element at the specified position.
 o max_size()
Returns the maximum number of elements allowed in the list.
 o merge(SingleList, Predicate2)
Merge merges the argument list into this list (both are assumed to be sorted).
 o pop_front()
Remove the first element in the list.
 o push_back(Object)
Insert at the end of the list.
 o push_front(Object)
Insert at the beginning of the list.
 o remove(Object)
Remove all elements in the list where the element is equals to the value.
 o reverse()
Reverse reverses the oerder of the element in the list.
 o size()
Returns the number of elements stored in the list.
 o sort(Predicate2)
Sort sorts the list according to the compare function object.
 o splice(Iterator, SingleList)
Insert the contents of another list into this list before position.
 o splice(Iterator, SingleList, Iterator)
Insert the element pointed to by the iterator i from another list into this list before a position.
 o splice(Iterator, SingleList, Iterator, Iterator)
Insert elements in the range into this list and remove the elements from the other list.
 o splice(SingleList)
Insert elements from another list into this list and remove the elements from the other list.
 o splice(SingleList, Iterator)
Insert an element from another list into this list and remove the element from the other list.
 o swap(SingleList)
Swaps the contents of the current list with those of the input list.
 o unique()
Unique erases all but the first element from every consecutive group of equal element in the list.

Constructors

 o SingleList
  public SingleList()
Constructs an empty list.
 o SingleList
  public SingleList(int n,
                    Object value)
Constructs a list with n element each pointing to value.
Parameters:
n - The number of elements the list will contain.
value - The object that is inserted in each in the list.
 o SingleList
  public SingleList(InputIterator first,
                    InputIterator last)
Constructs a list with elements found in the range [first,last).
Parameters:
first - The beginning of the range.
last - The end of the range.
 o SingleList
  public SingleList(SingleList list)
Constructs a list with all the elements from another list.
Parameters:
list - The elements in this list is copied into the newly contructed list.

Methods

 o flush
  public void flush()
Erase all the elements in the container.
 o swap
  public void swap(SingleList x)
Swaps the contents of the current list with those of the input list. The current list replaces x and vice versa.
 o equals
  public boolean equals(Object container)
Compare the elements in this container with the elements in another container.
Returns:
true is the elements match.
Overrides:
equals in class Object
 o begin
  public ForwardIterator begin()
Returns the iterator that represents the beginning of the list.
 o beginRef
  public ForwardIterator beginRef()
Returns a reference to the iterator that represents the beginning of the list.
 o end
  public ForwardIterator end()
Returns the iterator that represents the end of the list.
 o endRef
  public ForwardIterator endRef()
Returns a reference to the iterator that represents the end of the list.
 o beginGeneric
  public ForwardIterator beginGeneric()
Returns the iterator that represents the beginning of the list as a untyped iterator.
 o endGeneric
  public ForwardIterator endGeneric()
Returns the iterator that represents the end of the list as a untyped iterator.
 o front
  public Object front()
Returns the first element in the list.
 o back
  public Object back()
Returns the last element in the list.
 o size
  public int size()
Returns the number of elements stored in the list.
 o max_size
  public int max_size()
Returns the maximum number of elements allowed in the list.
 o empty
  public boolean empty()
Returns true if the list does not contain any elements.
 o push_front
  public void push_front(Object value)
Insert at the beginning of the list.
Parameters:
value - the element to insert.
 o push_back
  public void push_back(Object value)
Insert at the end of the list.
Parameters:
value - the element to insert.
 o insert
  public Iterator insert(Iterator position,
                         Object value)
Insert the element at the specified position.
Parameters:
position - An iterator that points to the position where the element is inserted.
value - The element.
 o insert
  public void insert(Iterator position,
                     int n,
                     Object value)
Insert n copy of the element at the specified position.
Parameters:
position - An iterator that points to the position where the elements are inserted.
n - The number of elements.
value - The element.
 o insert
  public void insert(Iterator position,
                     InputIterator first,
                     InputIterator last)
Insert the element in the range [first,last) into the list at the specified position.
Parameters:
position - An iterator that points to the position where the elements are inserted.
first - The beginning of the range
last - The end of the range
 o pop_front
  public void pop_front()
Remove the first element in the list.
 o erase
  public void erase(Iterator position)
Remove the element to which the iterator points.
Parameters:
position - the element to which the iterator point is removed.
 o erase
  public void erase(Iterator first,
                    Iterator last)
Remove the elements in the range [first,last) from the list.
Parameters:
first - The beginning of the range.
last - The end of the range.
 o splice
  public void splice(Iterator position,
                     SingleList x)
Insert the contents of another list into this list before position. All elements are removed from the other list. Essentially the contents of the orther list is transferred in into this list.
Parameters:
position - The elements are inserted before this position.
x - The source list.
 o splice
  public void splice(Iterator position,
                     SingleList x,
                     Iterator i)
Insert the element pointed to by the iterator i from another list into this list before a position. The element is removed from the other list.
Parameters:
position - The elements are inserted before this position.
x - The source list.
i - The source element.
 o splice
  public void splice(Iterator position,
                     SingleList x,
                     Iterator first,
                     Iterator last)
Insert elements in the range into this list and remove the elements from the other list. Elements in the range [first, last) is inserted into this list before position. The elements are removed from the other list.
Parameters:
position - The elements are inserted before this position.
x - The source list.
first - The beginning of the range.
last - The end of the range.
 o splice
  public void splice(SingleList x)
Insert elements from another list into this list and remove the elements from the other list.
Parameters:
x - The source list.
 o splice
  public void splice(SingleList x,
                     Iterator position)
Insert an element from another list into this list and remove the element from the other list.
Parameters:
x - The source list.
position - The element which will be inserted.
 o remove
  public void remove(Object value)
Remove all elements in the list where the element is equals to the value. Remove is stable, that is, the relative order of the elements that not removed is the same as their relative order in the original list.
Parameters:
value - The value that the elements are compared with.
 o unique
  public void unique()
Unique erases all but the first element from every consecutive group of equal element in the list. value. Remove is stable, that is, the relative order of the elements that not removed is the same as their relative order in the original list.
Parameters:
value - The value that the elements are compared with.
 o merge
  public void merge(SingleList x,
                    Predicate2 pred)
Merge merges the argument list into this list (both are assumed to be sorted). The merge is stable, that is, for equal elements in the two lists, the elements from this list always precede elements from the argument list. The argument list is empty after the merge.
Parameters:
x - The list that is merge into this list.
 o reverse
  public void reverse()
Reverse reverses the oerder of the element in the list.
 o sort
  public void sort(Predicate2 pred)
Sort sorts the list according to the compare function object. It is stable, that is, the relative order of the equal elements is preserved.

All Packages  Class Hierarchy  This Package  Previous  Next  Index